<template>
  <!-- 底部部分 => list有数据的时候，才展示  list.length > 0 -->
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ sum }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a
          href="#/"
          :class="{ selected: type === 'all' }"
          @click="changeType('all')"
          >全部</a
        >
      </li>
      <li>
        <a
          href="#/active"
          :class="{ selected: type === 'active' }"
          @click="changeType('active')"
          >进行中</a
        >
      </li>
      <li>
        <a
          href="#/completed"
          :class="{ selected: type === 'completed' }"
          @click="changeType('completed')"
          >已完成</a
        >
      </li>
    </ul>
    <!-- 有已完成的任务，才需要显示这个按钮 -->
    <button v-if="isShowClear" @click="clearAll" class="clear-completed">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true,
    },

    type: {
      type: String,
      required: true,
    },

    sum: {
      type: Number,
      required: true,
    },

    isShowClear: {
      type: Boolean,
      required: true,
    },

    //
    //   type:{
    //   type:Boolean,
    //   required: true
    //  },
  },
  computed: {},
  methods: {
    clearAll() {
      this.$emit('clearAll')
    },
    changeType(value) {
      this.$emit('changeType', value)
    },
  },
}
</script>

<style></style>
